package com.heima.admin.controller.v1;

import com.heima.admin.service.AdminService;
import com.heima.model.admin.dtos.RequestParamDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news")
public class AdminController {

    @Autowired
    private AdminService adminService;

    /**
     * 查询文章列表
     *
     * @return
     */
    @PostMapping("/list_vo")
    public ResponseResult getList(@RequestBody RequestParamDto dto) {
        System.out.println(dto);
        return adminService.getList(dto);
    }

    /**
     * 查询文章详情
     *
     * @param id
     * @return
     */
    @GetMapping("/one_vo/{id}")
    public ResponseResult getDetails(@PathVariable("id") Integer id) {
        return adminService.getDetails(id);
    }

    /**
     * 审核失败
     *
     * @param dto
     * @return
     */
    @PostMapping("/auth_fail")
    public ResponseResult fail(@RequestBody RequestParamDto dto) {
        return adminService.fail(dto);
    }

    /**
     * 审核成功
     *
     * @param dto
     * @return
     */
    @PostMapping("/auth_pass")
    public ResponseResult pass(@RequestBody RequestParamDto dto) {
        return adminService.pass(dto);
    }
}
